package com.acme.bankapp.service.bank;

import com.acme.bankapp.domain.bank.Account;
import com.acme.bankapp.domain.bank.Bank;
import com.acme.bankapp.domain.bank.Client;
import com.acme.bankapp.domain.bank.ClientRegistrationListener;
import com.acme.bankapp.exceptions.ClientExistException;
import com.acme.bankapp.exceptions.NotEnoughFundException;

public class BankService {

    public static void modifyBank(Bank bank, double amount) throws NotEnoughFundException {
        for(Client c: bank.clients) {
            if ( c != null ) {
                for (Account a: c.getAccounts()) {
                    if ( a != null ) {
                        if (amount > 0)
                            a.deposit(amount);
                        else
                            a.withdraw(-amount);
                    }
                }
            }
        }
    }

    public static void printData(Bank bank) {
        for (Client c: bank.clients) {
            if ( c != null ) {
                System.out.println(c);
            }
        }
    }
}
